package com.zrwl.poscloud.commons.fallback;

import com.zrwl.poscloud.commons.feign.GateServerFeignClient;
import com.zrwl.poscloud.commons.holder.RequestHolder;
import com.zrwl.poscloud.commons.utils.ResultUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 代理服务降级兜底方法【当服务不可用时会触发】
 *
 * @author: liusitong
 * @create: 2020-10-03-20:54
 */
@Component
@Slf4j
public class GateServerFeignFallback implements GateServerFeignClient {

    @Override
    public String getList() {
        HttpServletRequest request = RequestHolder.getRequest();
        StringBuffer requestURL = request.getRequestURL();
        log.error("代理服务出现异常，服务降级返回，请求路径: {}", requestURL);
        return ResultUtil.errorWithMessage("获取代理服务降级返回");
    }

    //废弃
    @Override
    public String getPosCodeByName(@RequestParam(value = "gateCode") String gateCode, @RequestParam(value = "equipmentName") String equipmentName) {
        HttpServletRequest request = RequestHolder.getRequest();
        StringBuffer requestURL = request.getRequestURL();
        log.error("代理服务出现异常，服务降级返回，请求路径: {}", requestURL);
        return ResultUtil.errorWithMessage("获取代理服务降级返回");
    }

    @Override
    public String updatePosTimeByName(String gateCode, String posCode) {
        HttpServletRequest request = RequestHolder.getRequest();
        StringBuffer requestURL = request.getRequestURL();
        log.error("代理服务出现异常，服务降级返回，请求路径: {}", requestURL);
        return ResultUtil.errorWithMessage("获取代理服务降级返回");
    }

    @Override
    public String getPosVersion(String gateCode, String posCode) {
        HttpServletRequest request = RequestHolder.getRequest();
        StringBuffer requestURL = request.getRequestURL();
        log.error("代理服务出现异常，服务降级返回，请求路径: {}", requestURL);
        return ResultUtil.errorWithMessage("获取代理服务降级返回");
    }

    //废弃
    @Override
    public String getPosIMMEUID(String gateCode, String equipmentName) {
        HttpServletRequest request = RequestHolder.getRequest();
        StringBuffer requestURL = request.getRequestURL();
        log.error("代理服务出现异常，服务降级返回，请求路径: {}", requestURL);
        return ResultUtil.errorWithMessage("获取代理服务降级返回");
    }

    @Override
    public String getPosCardPwd(String gateCode, String posCode) {
        HttpServletRequest request = RequestHolder.getRequest();
        StringBuffer requestURL = request.getRequestURL();
        log.error("代理服务出现异常，服务降级返回，请求路径: {}", requestURL);
        return ResultUtil.errorWithMessage("获取代理服务降级返回");
    }

    @Override
    public String initializationPOS(String gateCode, String posCode) {
        HttpServletRequest request = RequestHolder.getRequest();
        StringBuffer requestURL = request.getRequestURL();
        log.error("代理服务出现异常，服务降级返回，请求路径: {}", requestURL);
        return ResultUtil.errorWithMessage("获取代理服务降级返回");
    }

    @Override
    public String getPOSBlackPackageNo(String gateCode, String posCode) {
        HttpServletRequest request = RequestHolder.getRequest();
        StringBuffer requestURL = request.getRequestURL();
        log.error("代理服务出现异常，服务降级返回，请求路径: {}", requestURL);
        return ResultUtil.errorWithMessage("获取代理服务降级返回");
    }

    @Override
    public String getPOSTime(String gateCode, String posCode) {
        HttpServletRequest request = RequestHolder.getRequest();
        StringBuffer requestURL = request.getRequestURL();
        log.error("代理服务出现异常，服务降级返回，请求路径: {}", requestURL);
        return ResultUtil.errorWithMessage("获取代理服务降级返回");
    }

    @Override
    public String setEquipmentName(String gateCode, String posCode, String newEquipmentName) {
        HttpServletRequest request = RequestHolder.getRequest();
        StringBuffer requestURL = request.getRequestURL();
        log.error("代理服务出现异常，服务降级返回，请求路径: {}", requestURL);
        return ResultUtil.errorWithMessage("获取代理服务降级返回");
    }

    @Override
    public String getEquipmentNoUploadedRecord(String gateCode, String posCode) {
        HttpServletRequest request = RequestHolder.getRequest();
        StringBuffer requestURL = request.getRequestURL();
        log.error("代理服务出现异常，服务降级返回，请求路径: {}", requestURL);
        return ResultUtil.errorWithMessage("获取代理服务降级返回");
    }

    @Override
    public String updateICCardAuthListOrder(List<String> gateCodeList, String jsonStr) {
        HttpServletRequest request = RequestHolder.getRequest();
        StringBuffer requestURL = request.getRequestURL();
        log.error("代理服务出现异常，服务降级返回，请求路径: {}", requestURL);
        return ResultUtil.errorWithMessage("获取代理服务降级返回");
    }

    @Override
    public String noticeGateSyncICCardLogDataOrder(List<String> gateCodeList, String syncFlowCode) {
        HttpServletRequest request = RequestHolder.getRequest();
        StringBuffer requestURL = request.getRequestURL();
        log.error("代理服务出现异常，服务降级返回，请求路径: {}", requestURL);
        return ResultUtil.errorWithMessage("获取代理服务降级返回");
    }

    @Override
    public String updateGateEquipmentConfigOrder(String gateCode, String equipmentCode) {
        HttpServletRequest request = RequestHolder.getRequest();
        StringBuffer requestURL = request.getRequestURL();
        log.error("代理服务出现异常，服务降级返回，请求路径: {}", requestURL);
        return ResultUtil.errorWithMessage("获取代理服务降级返回");
    }

    @Override
    public String updateGateEquipmentConfigGateOrder(String gateCode) {
        HttpServletRequest request = RequestHolder.getRequest();
        StringBuffer requestURL = request.getRequestURL();
        log.error("代理服务出现异常，服务降级返回，请求路径: {}", requestURL);
        return ResultUtil.errorWithMessage("获取代理服务降级返回");
    }

    @Override
    public String noticeGateSyncEmployeeDataOrder(List<String> gateCodeList, String syncCode) {
        HttpServletRequest request = RequestHolder.getRequest();
        StringBuffer requestURL = request.getRequestURL();
        log.error("代理服务出现异常，服务降级返回，请求路径: {}", requestURL);
        return ResultUtil.errorWithMessage("获取代理服务降级返回");
    }

    @Override
    public String getCompanyEquipmentOnlineList(String ownerUid) {
        HttpServletRequest request = RequestHolder.getRequest();
        StringBuffer requestURL = request.getRequestURL();
        log.error("代理服务出现异常，服务降级返回，请求路径: {}", requestURL);
        return ResultUtil.errorWithMessage("获取代理服务降级返回");
    }

    @Override
    public String getCompanyEquipmentOnlineInfo(String ownerUid) {
        HttpServletRequest request = RequestHolder.getRequest();
        StringBuffer requestURL = request.getRequestURL();
        log.error("代理服务出现异常，服务降级返回，请求路径: {}", requestURL);
        return ResultUtil.errorWithMessage("获取代理服务降级返回");
    }

    @Override
    public String createNewOutSideLog(String jsonStr) {
        HttpServletRequest request = RequestHolder.getRequest();
        StringBuffer requestURL = request.getRequestURL();
        log.error("代理服务出现异常，服务降级返回，请求路径: {}", requestURL);
        return ResultUtil.errorWithMessage("获取代理服务降级返回");
    }

    @Override
    public String outsideInterfaceTransfer(String jsonStr) {
        HttpServletRequest request = RequestHolder.getRequest();
        StringBuffer requestURL = request.getRequestURL();
        log.error("代理服务出现异常，服务降级返回，请求路径: {}", requestURL);
        return ResultUtil.errorWithMessage("获取代理服务降级返回");
    }

}
